package com.addcn.pushlibrary.vivo;

import android.content.Context;
import android.os.PowerManager;

import com.addcn.pushlibrary.LPush;
import com.addcn.pushlibrary.bean.PMessage;
import com.vivo.push.model.UPSNotificationMessage;
import com.vivo.push.model.UnvarnishedMessage;
import com.vivo.push.sdk.OpenClientPushMessageReceiver;
import com.xiaomi.mipush.sdk.MiPushCommandMessage;
import com.xiaomi.mipush.sdk.MiPushMessage;
import com.xiaomi.mipush.sdk.PushMessageReceiver;

import java.util.Map;

import static android.os.PowerManager.ACQUIRE_CAUSES_WAKEUP;
import static android.os.PowerManager.SCREEN_DIM_WAKE_LOCK;

/**
 * author:luwenbo
 * created on date : 2019-05-21
 * content:
 * describe:
 */
public class LVivoReceive extends OpenClientPushMessageReceiver {

    private PMessage getMessage(UPSNotificationMessage upsNotificationMessage) {
        PMessage pMessage = new PMessage();
        Map<String, String> extra = upsNotificationMessage.getParams();
        if (extra != null) {
            pMessage.setId(extra.get("msg_id") == null ? "" : extra.get("msg_id"));
            pMessage.setUrl(extra.get("url"));
            String clean = "0";
            if (extra.get("clean_notification") != null && !extra.get("clean_notification").equals("")) {
                clean = extra.get("clean_notification");
            }
            pMessage.setClean(clean);
            if (!extra.containsKey("extra")) {
                pMessage.setExtra(extra.get("extra") == null ? "" : extra.get("extra"));
            }
        }

        pMessage.setTitle(upsNotificationMessage.getTitle());
        pMessage.setContent(upsNotificationMessage.getContent());
        pMessage.setBigThumb(upsNotificationMessage.getCoverUrl());
        pMessage.setFromType(PMessage.FROM_JPUSH);
        return pMessage;
    }

    @Override
    public void onNotificationMessageClicked(Context context, UPSNotificationMessage upsNotificationMessage) {
        PMessage pMessage = getMessage(upsNotificationMessage);
        LPush.getInstance(context).onNotificationClicked(pMessage);
    }

    @Override
    public void onReceiveRegId(Context context, String s) {

    }

}
